package com.lyy.mybatis.sensitive.demo.domain.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.lyy.mybatis.sensitive.annotation.SensitiveField;
import com.lyy.mybatis.sensitive.annotation.SensitiveTable;
import com.lyy.mybatis.sensitive.demo.dbhandler.OtherJsonTypeHandler;
import com.lyy.mybatis.sensitive.demo.domain.dto.Other;
import com.lyy.mybatis.sensitive.secret.Aes;
import com.lyy.mybatis.sensitive.secret.Secret62;
import lombok.Data;
import lombok.experimental.Accessors;

/**
 * @author lyy 2024/11/26
 */
@Data
@Accessors(chain = true)
@TableName(value = "user", autoResultMap = true)
@SensitiveTable//标明该类为敏感数据表
public class UserEntity {

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    //标明该字段为敏感字段，并指定Secret62加密算法
    //Secret62自定义的加密算法,仅支持数字和英文的加密,可支持加密后的模糊查询
    @SensitiveField(Secret62.class)
    private String mobile;

    // 明示该字段为敏感字段，并指定Aes加密算法
    @SensitiveField(Aes.class)
    private String addr;

    @TableField(typeHandler = OtherJsonTypeHandler.class)
    private Other other;
}
